home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 14 / CU Amiga Magazine's Super CD-ROM 14 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-09].iso / CUCD / Programming / Mesa-2.2 / src / xform.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-03-13  |  2.5 KB  |  87 lines

  1. /* $Id: xform.h,v 1.3 1996/11/08 02:20:39 brianp Exp $ */
  2.  
  3. /*
  4.  * Mesa 3-D graphics library
  5.  * Version:  2.0
  6.  * Copyright (C) 1995-1996  Brian Paul
  7.  *
  8.  * This library is free software; you can redistribute it and/or
  9.  * modify it under the terms of the GNU Library General Public
  10.  * License as published by the Free Software Foundation; either
  11.  * version 2 of the License, or (at your option) any later version.
  12.  *
  13.  * This library is distributed in the hope that it will be useful,
  14.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16.  * Library General Public License for more details.
  17.  *
  18.  * You should have received a copy of the GNU Library General Public
  19.  * License along with this library; if not, write to the Free
  20.  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  */
  22.  
  23.  
  24. /*
  25.  * $Log: xform.h,v $
  26.  * Revision 1.3  1996/11/08 02:20:39  brianp
  27.  * added gl_xform_texcoords_4fv()
  28.  *
  29.  * Revision 1.2  1996/11/04 01:39:46  brianp
  30.  * removed MAP_X(), MAP_Y() and MAP_Z() macros
  31.  *
  32.  * Revision 1.1  1996/09/13 01:38:16  brianp
  33.  * Initial revision
  34.  *
  35.  */
  36.  
  37.  
  38. #ifndef XFORM_H
  39. #define XFORM_H
  40.  
  41.  
  42. #include "types.h"
  43.  
  44.  
  45. /*
  46.  * Transform a point (column vector) by a matrix:   Q = M * P
  47.  */
  48. #define TRANSFORM_POINT( Q, M, P )                    \
  49.    Q[0] = M[0] * P[0] + M[4] * P[1] + M[8] *  P[2] + M[12] * P[3];    \
  50.    Q[1] = M[1] * P[0] + M[5] * P[1] + M[9] *  P[2] + M[13] * P[3];    \
  51.    Q[2] = M[2] * P[0] + M[6] * P[1] + M[10] * P[2] + M[14] * P[3];    \
  52.    Q[3] = M[3] * P[0] + M[7] * P[1] + M[11] * P[2] + M[15] * P[3];
  53.  
  54.  
  55. /*
  56.  * Transform a normal (row vector) by a matrix:  [NX NY NZ] = N * MAT
  57.  */
  58. #define TRANSFORM_NORMAL( NX, NY, NZ, N, MAT )        \
  59.    NX = N[0] * MAT[0] + N[1] * MAT[1] + N[2] * MAT[2];    \
  60.    NY = N[0] * MAT[4] + N[1] * MAT[5] + N[2] * MAT[6];    \
  61.    NZ = N[0] * MAT[8] + N[1] * MAT[9] + N[2] * MAT[10];    \
  62.  
  63.  
  64.  
  65. extern void gl_xform_points_4fv( GLuint n, GLfloat q[][4], const GLfloat m[16],
  66.                                  GLfloat p[][4] );
  67.  
  68.  
  69. extern void gl_xform_points_3fv( GLuint n, GLfloat q[][4], const GLfloat m[16],
  70.                                  GLfloat p[][3] );
  71.  
  72.  
  73. extern void gl_xform_normals_3fv( GLuint n, GLfloat v[][3],
  74.                                   const GLfloat m[16],
  75.                                   GLfloat u[][3], GLboolean normalize );
  76.  
  77.  
  78. extern void gl_transform_vector( GLfloat u[4],
  79.                  const GLfloat v[4], const GLfloat m[16] );
  80.  
  81.  
  82. extern void gl_xform_texcoords_4fv( GLuint n, GLfloat tc[][4],
  83.                                     const GLfloat m[16] );
  84.  
  85.  
  86. #endif
  87.